﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Xml;
using System.IO;

namespace TimeSheetNote
{
    public partial class FormHistory : Form
    {
        public FormHistory()
        {
            InitializeComponent();
        }

        void LoadHistory(DateTime dt)
        {
            txb.Clear();
            DateTime adtDay = cld.SelectionStart.Date;
            try
            {
                List<TaskEl> tl = Gl.GetDayTasks(adtDay);
                for (int i = 0; i < tl.Count; i++)
                {
                    int ttlTime = tl[i].TotalTime;

                    txb.AppendText(DateTime.Today.AddSeconds(tl[i].Days[adtDay]).ToString("HH:mm") + " -> " + tl[i].Text + " (всего " + (ttlTime / 3600).ToString("00") + ":" + ((ttlTime - (ttlTime / 3600) * 3600) / 60).ToString("00") + ")");
                    txb.AppendText("\r\n------------------------------------------\r\n");
                }
            }
            catch (Exception ex) { MessageBox.Show("Ошибка загрузки сохранения: " + ex.Message); }
        }

        private void monthCalendar1_DateChanged(object sender, DateRangeEventArgs e)
        {
            LoadHistory(cld.SelectionStart);
        }

        private void FormHistory_Shown(object sender, EventArgs e)
        {
            cld.SelectionStart = DateTime.Now;
            cld.SelectionEnd = DateTime.Now;
        }
    }
}
